// pages/medicine/pages/information2/information2.js
var app =getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    doctor: {
      doctorName: '小花',
      nmDepartment: '骨科',
      jobType: 1,
      nmHospital: '山西大医院',
      patientCount: 100,
      askNum: 10,
      bgGoodAt: ['脚气', '骨科'],
      briefIntroduce: '专业骨科20年',
      userIcon: "/assets/images/796.png"
    },
    myDoctor: '', //健康顾问
    myNurse: '', //护理顾问
    myTeam: '', //团队顾问
    lookOverBoo: 0, //0为可签约
    relation: {
      signState: 2, //显示当前用户与顾问状态 0为  1为   2为可签约
    },
    confirmFlag: 0, //0为已签约成功 1为还没有签约成功
    reasonList: ['技术菜', '收费高', '不回信息'],
    arr: [{
        img: '/assets/images/xiong1.png',
        name: '小花',
        title: '主治医师',
        department: '骨科',
        number: 20,
        evaluate: 2.1,
        good: '接骨,按摩'
      },
      {
        img: '/assets/images/xiong1.png',
        name: '小花',
        title: '主治医师',
        department: '骨科',
        number: 20,
        evaluate: 2.1,
        good: '接骨,按摩'
      },
      {
        img: '/assets/images/xiong1.png',
        name: '小花',
        title: '主治医师',
        department: '骨科',
        number: 20,
        evaluate: 2.1,
        good: '接骨,按摩'
      },
      {
        img: '/assets/images/xiong1.png',
        name: '小花',
        title: '主治医师',
        department: '骨科',
        number: 20,
        evaluate: 2.1,
        good: '接骨,按摩'
      },
      {
        img: '/assets/images/xiong1.png',
        name: '小花',
        title: '主治医师',
        department: '骨科',
        number: 20,
        evaluate: 2.1,
        good: '接骨,按摩'
      },
      {
        img: '/assets/images/xiong1.png',
        name: '小花',
        title: '主治医师',
        department: '骨科',
        number: 20,
        evaluate: 2.1,
        good: '接骨,按摩'
      }
    ],
    //咨询服务
    service: [{
        cdInterroga: 290101,
        saleMoney: 1,
        currentPrice: 1000,
        servicePrice: 2000,
        saleMoney: 1
      },
      {
        cdInterroga: 290102,
        saleMoney: 1,
        currentPrice: 1000,
        servicePrice: 2000,
        saleMoney: 1
      }
    ],
    //服务列表
    servicePackage: [{
        title: '手术快约',
        state: 0,
        id: 1
      },
      {
        title: '专家坐诊',
        state: 1,
        id: 2
      },
      {
        title: '点名会诊',
        state: 0,
        id: 3
      }
    ],
    page: 0,
    prenumber: 12,
    loadingBoo: !0,
    moreBoo: !0,
    currentPlay: -1,
    saidList: [{
        nameUrl: '/assets/images/head.png',
        saidId: 1,
        name: '小花',
        datTime: '2018-10-23',
        patientCount: 3,
        monentIdea: '人是怎么感冒的',
        contentType: 1,
        playFlag: 1,
        duration: 1,
        contentImg: ['/assets/images/head.png', '/assets/images/head.png', ],
        content: 1,
        title: '病毒引起的',
        coverImg: '/assets/images/head.png',
        eduType: 2
      },
      {
        nameUrl: '/assets/images/head.png',
        saidId: 1,
        name: '小花',
        datTime: '2018-10-23',
        patientCount: 3,
        monentIdea: '人是怎么感冒的',
        contentType: 1,
        playFlag: 1,
        duration: 1,
        contentImg: ['/assets/images/head.png', '/assets/images/head.png', ],
        content: 1,
        title: '病毒引起的',
        coverImg: '/assets/images/head.png',
        eduType: 2
      },
      {
        nameUrl: '/assets/images/head.png',
        saidId: 1,
        name: '小花',
        datTime: '2018-10-23',
        patientCount: 3,
        monentIdea: '人是怎么感冒的',
        contentType: 1,
        playFlag: 1,
        duration: 1,
        contentImg: ['/assets/images/head.png', '/assets/images/head.png', ],
        content: 1,
        title: '病毒引起的',
        coverImg: '/assets/images/head.png',
        eduType: 2
      }
    ],
    choices: 1, //跳简介，成员等
    myDcoBoo: !0,
    lookOverBoo: 0, //0为可签约
    backBoo: !1,
    modelBoo: !1,
  },
  //跳简介，成员等
  choice: function(e) {
    let id = e.target.id;
    this.setData({
      choices: id
    })
  },
  //看医说
  record: function(a) {
    wx.navigateTo({
      url: "/hyb_yl/backstageLife/pages/particulars/particulars"
    });
  },
  //放大医说图片
  previewImage: function(a) {
    // var t = this;
    // console.log(a), wx.previewImage({
    //   current: a.target.dataset.url,
    //   urls: t.data.saidList[a.currentTarget.dataset.index].contentImg
    // });
    wx.previewImage({
      current: '/assets/images/head.png',
      urls: '/assets/images/head.png'
    });
  },
  //进入服务列表
  special: function(e) {
    console.log(e)
    let that = this;
    let id = e.currentTarget.dataset.id;
    let state = e.currentTarget.dataset.state;
    let index = e.currentTarget.dataset.index;
    let servicePackage = that.data.servicePackage[index].title;
    if (state == 0) {
      wx.showToast({
        title: servicePackage + '现在不约',
        icon: "none",
        duration: 2e3
      })
    } else {
      wx.navigateTo({
        url: '/hyb_yl/backstageGroceries/pages/choosePerson/choosePerson?id=' + id
      })
    }
  },
  selectBtn: function() {
    if (0 != this.data.doctor.activeFlag) {
      var t = this;
      if (1 == t.data.personalFlag)
        if (t.data.personalArr.gender && t.data.personalArr.name && t.data.personalArr.phone) {
          if (0 != t.data.myDoctor.length) return console.log(111), void t.setData({
            yetFlag: !0,
            yetMsg: "当前您已与其他健康顾问签约，不能再签约此健康顾问，需要与当前健康顾问解约后，才能与此健康顾问签约。",
            targetDoctor: t.data.myDoctor
          });
          if (0 != t.data.myNurse.length) return console.log(2222), void t.setData({
            yetFlag: !0,
            yetMsg: "当前您已与护理顾问签约，不能再签约健康顾问，需要与护理顾问解约后，才能与健康顾问签约。",
            targetDoctor: t.data.myNurse
          });
          if (0 != t.data.myTeam.length) return console.log(3333), void t.setData({
            yetFlag: !0,
            yetMsg: "当前您已与团队顾问签约，不能再签约健康顾问，需要与团队顾问解约后，才能与健康顾问签约。",
            targetDoctor: t.data.myTeam
          });
          this.setData({
            modelBoo: !0
          });
        } else wx.showModal({
          title: "个人信息未完善",
          cancelText: "以后再说",
          confirmText: "去完善",
          confirmColor: "#3b4ca9",
          success: function(t) {
            t.confirm && wx.navigateTo({
              url: "/hyb_yl/userShopping/pages/index1/index1"
            });
          }
        });
      else {
        if (0 != t.data.myDoctor.length) return console.log(111), void t.setData({
          yetFlag: !0,
          yetMsg: "当前您已与其他健康顾问签约，不能再签约此健康顾问，需要与当前健康顾问解约后，才能与此健康顾问签约。",
          targetDoctor: t.data.myDoctor
        });
        if (0 != t.data.myNurse.length) return console.log(2222), void t.setData({
          yetFlag: !0,
          yetMsg: "当前您已与护理顾问签约，不能再签约健康顾问，需要与护理顾问解约后，才能与健康顾问签约。",
          targetDoctor: t.data.myNurse
        });
        if (0 != t.data.myTeam.length) return console.log(3333), void t.setData({
          yetFlag: !0,
          yetMsg: "当前您已与团队顾问签约，不能再签约健康顾问，需要与团队顾问解约后，才能与健康顾问签约。",
          targetDoctor: t.data.myTeam
        });
        this.setData({
          modelBoo: !0
        });
      }
    } else {
      var a = this.data.doctor.stopMedNotify || "";
      wx.showModal({
        title: "停诊中",
        content: a,
        showCancel: !1,
        confirmText: "取消",
        confirmColor: "#3b4ca9",
        success: function(t) {
          t.confirm;
        }
      });
    }
  },
  //取消申请
  cancelBtn: function(a) {
    var o = a.target.dataset.signid,
      that = this;
    that.setData({
      signId: o
    })
    let confirmFlag = that.data.confirmFlag;
    if (confirmFlag == 1) {
      wx.showModal({
        title: "团队已同意，不能取消申请",
        showCancel: !1,
        confirmText: "我知道了",
        confirmColor: "#3b4ca9",
        success: function() {
          that.setData({

          })
        }
      });
    } else {
      wx.showModal({
        title: "确定要取消申请吗？",
        confirmColor: "#3b4ca9"
      });
      that.setData({
        backBoo: !0,
        confirmFlag: 0,
        lookOverBoo: 2,
        'relation.signState': 2
      })
    }
    // , e.data.confirmFlag && (e.data.confirmFlag = !1), t.default.getDoctor(e);
  },
  abolishBtn: function() {
    this.setData({
      modelBoo: !1
    });
  },
  //签约
  signedBtn: function() {
    var a = this;
    // t.default.signedBtn(a);
    // console.log(t)
    a.setData({
      // yetFlag: 2,
      myDoctor: 1,
      modelBoo: !1,
      'relation.signState': 0,
      backBoo: !0,
      lookOverBoo: 3
      // yetMsg: "请等待对方同意",
    })
    console.log(a.data.relation.signState)
    console.log(a.data.backBoo)
    setTimeout(function() {
      a.setData({
        confirmFlag: 1,
        myDcoBoo: !1,
        lookOverBoo: 1,
        'relation.signState': 1
      })
    }, 3000)
  },
  //解约
  relieveBtn: function() {
    this.setData({
      ReasonFlag: !0,
    })
  },
  //去问诊
  goInquiry: function(e) {
    let index = e.currentTarget.dataset.index;
    let cdinterroga = this.data.service[index].cdInterroga;
    console.log(index)
    wx.navigateTo({
      url: "/hyb_yl/userCommunicate/pages/healthConsultant/healthConsultant?cdinterroga=" + cdinterroga
    });
  },
  yetBtn: function() {
    return void this.setData({
      yetFlag: !1
    });
  },
  chooseReason: function(t) {
    console.log(t), this.setData({
      reasonIndex: t.target.dataset.disreason,
      reasonText: t.target.dataset.text
    });
  },
  offBtn: function() {
    this.setData({
      ReasonFlag: !1
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this
    var t_id = options.t_id
    that.setData({
      t_id: t_id
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {
    this.getDocteam()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  getDocteam: function() {
    var that = this
    var t_id = that.data.t_id
    app.util.request({
      'url': 'entry/wxapp/Seledocteam',
      data: {
        t_id: t_id,
        op: 'post'
      },
      success: function(res) {
        console.log(res)
        that.setData({
          teaminfo:res.data.data
        })
      }
    })
  }
})